package com.shengyin.ec.model.dao.mail;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.shengyin.ec.model.dao.BaseDaoImpl;
import com.shengyin.ec.model.entity.Mail;

@Repository("mailDao")
public class MailDaoImpl extends BaseDaoImpl<Mail> implements MailDao {

	@Override
	public void deleteAllMail(long[] ids) {
		Mail mail=null;
		List<Mail> mailList=new ArrayList<Mail>(0);
		for(long id:ids)
		{
			mail=super.get(id);
			mailList.add(mail);
		}
		super.deleteAll(mailList);
	}

	@Override
	public void deleteMailByAuthor(String mailAuthor) {
		
	}

	@Override
	public List<Mail> getMailList() {
		return null;
	}

	@Override
	public void deleteSelectedMail(Long[] ids) {
		Mail mail=null;
		List<Mail> mailList=new ArrayList<Mail>(0);
		for(long id:ids)
		{
			mail=super.get(id);
			mailList.add(mail);
		}
		super.deleteAll(mailList);
		
	}
	
	

	@Override
	public List<Mail> getMailList(int offset, int pagesize) {
		// TODO Auto-generated method stub
		return super.findByPage("from Mail mail", offset, pagesize);
	}

	@Override
	public Long getTotal() {
		return (Long) super.find("select count(*) from Mail")	.get(0);
	}

}
